package com.ruoyi.college_dept.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.college_dept.domain.CollegeDept;
import com.ruoyi.college_dept.service.ICollegeDeptService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 成都大学部门Controller
 * 
 * @author cjy
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/college_dept/college_dept")
public class CollegeDeptController extends BaseController
{
    @Autowired
    private ICollegeDeptService collegeDeptService;

    /**
     * 查询成都大学部门列表
     */
    @PreAuthorize("@ss.hasPermi('college_dept:college_dept:list')")
    @GetMapping("/list")
    public AjaxResult list(CollegeDept collegeDept)
    {
        List<CollegeDept> list = collegeDeptService.selectCollegeDeptList(collegeDept);
        return success(list);
    }

    /**
     * 导出成都大学部门列表
     */
    @PreAuthorize("@ss.hasPermi('college_dept:college_dept:export')")
    @Log(title = "成都大学部门", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CollegeDept collegeDept)
    {
        List<CollegeDept> list = collegeDeptService.selectCollegeDeptList(collegeDept);
        ExcelUtil<CollegeDept> util = new ExcelUtil<CollegeDept>(CollegeDept.class);
        util.exportExcel(response, list, "成都大学部门数据");
    }

    /**
     * 获取成都大学部门详细信息
     */
    @PreAuthorize("@ss.hasPermi('college_dept:college_dept:query')")
    @GetMapping(value = "/{deptId}")
    public AjaxResult getInfo(@PathVariable("deptId") Long deptId)
    {
        return success(collegeDeptService.selectCollegeDeptByDeptId(deptId));
    }

    /**
     * 新增成都大学部门
     */
    @PreAuthorize("@ss.hasPermi('college_dept:college_dept:add')")
    @Log(title = "成都大学部门", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CollegeDept collegeDept)
    {
        return toAjax(collegeDeptService.insertCollegeDept(collegeDept));
    }

    /**
     * 修改成都大学部门
     */
    @PreAuthorize("@ss.hasPermi('college_dept:college_dept:edit')")
    @Log(title = "成都大学部门", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CollegeDept collegeDept)
    {
        return toAjax(collegeDeptService.updateCollegeDept(collegeDept));
    }

    /**
     * 删除成都大学部门
     */
    @PreAuthorize("@ss.hasPermi('college_dept:college_dept:remove')")
    @Log(title = "成都大学部门", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deptIds}")
    public AjaxResult remove(@PathVariable Long[] deptIds)
    {
        return toAjax(collegeDeptService.deleteCollegeDeptByDeptIds(deptIds));
    }
}
